package com.tbit.uqbike.compalint.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tbit.uqbike.annos.Excel;
import com.tbit.uqbike.compalint.enums.ComplaintStatusEnum;
import com.tbit.uqbike.compalint.enums.PlatformEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 客诉分页条目
 *
 * @author <a href="mailto:zhang.zhiliang@tbit.com.cn">Zhang ZhiLiang</a>
 * @version 1.0
 * @see <a href="http://adsl1.tbit.com.cn:21490/pages/viewpage.action?pageId=82182491">订单号规范</a>
 * @since 2025/2/14
 */
@Data
public class ComplaintVO {
    /**投诉单号*/
    @Excel(name = "投诉单号", sort = 1)
    private String complaintId;
    /**投诉时间*/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "投诉时间", dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 2)
    private Date complaintTime;
    /**投诉平台码*/
    private Integer platform;
    /**投诉平台*/
    @Excel(name = "投诉平台", sort = 3)
    private String complaintPlatform;
    /**投诉金额*/
    @Excel(name = "投诉金额", sort = 4)
    private String orderMoneyStr;
    /**投诉金额 单位：分*/
    @JsonIgnore
    private Integer orderMoney;
    /**问题描述*/
    @Excel(name = "问题描述", sort = 5)
    private String description;
    /**图片url*/
    @JsonIgnore
    private String picture;
    /**图片oss url 集合*/
    private List<String> pictureUrls;
    /**投诉人手机号*/
    @Excel(name = "投诉人手机号", sort = 6)
    private String phone;
    /**业务平台订单号*/
    @Excel(name = "业务平台订单号", sort = 7)
    private String orderNO;
    /**操作人*/
    @Excel(name = "操作人", sort = 8)
    private String operator;
    /**操作人手机号*/
    @Excel(name = "操作人手机号", sort = 9)
    private String operatorPhone;
    /**处理状态编码*/
    @JsonIgnore
    private Integer status;
    /**处理状态*/
    @Excel(name = "处理状态", sort = 10)
    private String statusStr;

    /**
     * 格式化返回值
     *
     */
    public void format() {
        // 格式化金额为元   字符串
        BigDecimal orderMoneyDecimal = new BigDecimal(orderMoney);
        orderMoneyStr = orderMoneyDecimal.divide(BigDecimal.valueOf(100),2, RoundingMode.HALF_UP).toString();
        // 图片路径切割
        if (Objects.nonNull(picture)){
            String[] urls = picture.split(";");
            pictureUrls = Arrays.asList(urls);
        }
        // 枚举转换
        complaintPlatform = PlatformEnum.getByCode(platform).getName();
        statusStr = ComplaintStatusEnum.getByCode(status).getName();
    }


}
